package com.traceability.trace.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.traceability.common.annotation.Log;
import com.traceability.common.core.controller.BaseController;
import com.traceability.common.core.domain.AjaxResult;
import com.traceability.common.enums.BusinessType;
import com.traceability.trace.domain.Qualityinspection;
import com.traceability.trace.service.IQualityinspectionService;
import com.traceability.common.utils.poi.ExcelUtil;
import com.traceability.common.core.page.TableDataInfo;

/**
 * 检测信息管理Controller
 * 
 * @author xulin
 * @date 2025-01-09
 */
@RestController
@RequestMapping("/traceability-trace/qualityinspection")
public class QualityinspectionController extends BaseController
{
    @Autowired
    private IQualityinspectionService qualityinspectionService;

    /**
     * 查询检测信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('traceability-trace:qualityinspection:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qualityinspection qualityinspection)
    {
        startPage();
        List<Qualityinspection> list = qualityinspectionService.selectQualityinspectionList(qualityinspection);
        return getDataTable(list);
    }

    /**
     * 导出检测信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('traceability-trace:qualityinspection:export')")
    @Log(title = "检测信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Qualityinspection qualityinspection)
    {
        List<Qualityinspection> list = qualityinspectionService.selectQualityinspectionList(qualityinspection);
        ExcelUtil<Qualityinspection> util = new ExcelUtil<Qualityinspection>(Qualityinspection.class);
        util.exportExcel(response, list, "检测信息管理数据");
    }

    /**
     * 获取检测信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('traceability-trace:qualityinspection:query')")
    @GetMapping(value = "/{inspectionId}")
    public AjaxResult getInfo(@PathVariable("inspectionId") Long inspectionId)
    {
        return success(qualityinspectionService.selectQualityinspectionByInspectionId(inspectionId));
    }

    /**
     * 新增检测信息管理
     */
    @PreAuthorize("@ss.hasPermi('traceability-trace:qualityinspection:add')")
    @Log(title = "检测信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qualityinspection qualityinspection)
    {
        return toAjax(qualityinspectionService.insertQualityinspection(qualityinspection));
    }

    /**
     * 修改检测信息管理
     */
    @PreAuthorize("@ss.hasPermi('traceability-trace:qualityinspection:edit')")
    @Log(title = "检测信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qualityinspection qualityinspection)
    {
        return toAjax(qualityinspectionService.updateQualityinspection(qualityinspection));
    }

    /**
     * 删除检测信息管理
     */
    @PreAuthorize("@ss.hasPermi('traceability-trace:qualityinspection:remove')")
    @Log(title = "检测信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inspectionIds}")
    public AjaxResult remove(@PathVariable Long[] inspectionIds)
    {
        return toAjax(qualityinspectionService.deleteQualityinspectionByInspectionIds(inspectionIds));
    }
}
